package demo;

import java.util.HashSet;
import java.util.Set;

/**
 * 自行车场（ 池 ）
 * @author ZhouWeiBo
 * @create 2022/6/7
 */
public class BikeFactory {
    private static BikeFactory instance = new BikeFactory();
    private Set<Bike> pool = new HashSet<>();
    public static BikeFactory getInstance(){
        return instance;
    }

    private BikeFactory() {
        for (int i = 0 ; i < 2 ; i ++ ){
            pool.add(new MoBike(i));
        }
    }

    public Bike getBike(){
        for (Bike bike : pool){
            if (bike.status == 0)
                return bike;
        }
        return null;
    }

}
